<?php 
	// Selecionar a Pessoa via autocomplete;
	// Definir o user_id com o usuario logado;
	
	echo $this->Html->script('loans', array('inline' => false));
	//echo $this->Html->script('jquery/plugins/autocomplete', array('inline' => false));
?>
<script>

</script>
<style>
		label, input { display:block; }
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		
		div#users-contain { margin: 10px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .2em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
		.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>
<div class="loans form ui-widget">
<?php echo $this->Session->flash(); ?>
<?php echo $this->Form->create('Loan');?>
	<div id="form">
 		<h2><?php __('Add Loan'); ?></h2>
<?php
		echo $this->Form->hidden('person_id');
		/*
		echo $this->Form->input('person_registry', array(
									'id' => 'LoanPersonRegistry', 
									'type' => 'text', 
									'class' => 'text ui-widget-content ui-corner-all')
								);
		*/
		echo $this->Form->input('person_name', array(
									'id' => 'LoanPersonName', 
									'type' => 'text', 
									'class' => 'text ui-widget-content ui-corner-all')
								);
		echo $this->Form->input('created', array(
									'id' => 'LoanCreated', 
									'type' => 'text', 
									'class' => 'text ui-widget-content ui-corner-all')
								);
		echo $this->Form->input('estimated_devolution', array(
									'id' => 'LoanEstimatedDevolution', 
									'type' => 'text', 
									'class' => 'text ui-widget-content ui-corner-all')
								);
		// Adicionar ID do usuario pela auth
		echo $this->Form->hidden('user_id', array('value' => '4d7a7c4b-73d8-41a3-9395-08ccba012c68'));
?>
<?php echo $this->Form->end(__('Submit', true));?>
	</div>
	
	<div id="tabs">
		<ul>
			<li><a href="#tab-copies"><?php __('Copies'); ?></a></li>
		</ul>
		<div id="tab-copies">
			<div id="loan-contain" class="ui-widget">
				<button id="add" type="button"><?php __('Add Copy'); ?></button>
				<br /><br />
				<table id="users" class="ui-widget ui-widget-content">
					<thead>
						<tr class="ui-widget-header ">
							<th><?php __('#'); ?></th>
							<th><?php __('Publication'); ?></th>
							<th class="actions"><?php __('Options');?></th>
						</tr>
					</thead>
					<tbody>
						<!--
						<tr>
							<td>1024</td>
							<td>C# Unleashed</td>
							<td class="actions">
								<?php echo $this->Html->link(__('Delete', true), array('controller' => 'copies', 'action' => 'view')); ?>
							</td>
						</tr>
						-->
					</tbody>
				</table>
			</div>
		</div>
 	</div>
</div>
<div id="dialog-form" title="<?php __('Add Copy');?>">
	<form>
	<fieldset>
		<?php echo $this->Form->input('copy_id', array(
					'type' => 'text', 
					'class' => 'text ui-widget-content ui-corner-all',
					'label' => __('Copy Id', true)
		)); ?>
	</fieldset>
	</form>
</div>
<div class="actions">
	<h3><?php __('Actions'); ?></h3>
	<ul>

		<li><?php echo $this->Html->link(__('List Loans', true), array('action' => 'index'));?></li>
		<li><?php echo $this->Html->link(__('List Devolutions', true), array('action' => 'devolution'));?></li>
		<li><?php echo $this->Html->link(__('List People', true), array('controller' => 'people', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Person', true), array('controller' => 'people', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Copies', true), array('controller' => 'copies', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Copy', true), array('controller' => 'copies', 'action' => 'add')); ?> </li>
	</ul>
</div>